package iogame.test.login.action;

import com.iohao.game.action.skeleton.annotation.ActionController;
import com.iohao.game.action.skeleton.annotation.ActionMethod;
import com.iohao.game.action.skeleton.core.exception.MsgException;
import com.iohao.game.action.skeleton.core.flow.FlowContext;

import iogame.test.login.pb.LoginInfo;
import iogame.test.login.pb.LoginVerify;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@ActionController(1)
public class LoginAction {

    /**
     * 登录业务
     *
     * @param loginVerify loginVerify
     * @param flowContext flowContext
     * @return UserInfo
     * @throws MsgException e
     */
    @ActionMethod(1)
    public LoginInfo loginVerify(LoginVerify loginVerify, FlowContext flowContext) throws MsgException {
        // 登录业务码

        return loginInfo(123, "123456");
    }

    private LoginInfo loginInfo(int uid, String password) {
        LoginInfo loginInfo = new LoginInfo();
        loginInfo.ip = "127.0.0.1";
        loginInfo.port = 0;
        loginInfo.rsaPrivateKey = "";
        loginInfo.token = "";
        loginInfo.password = password;
        return loginInfo;
    }
}
